# -*- ecoding: utf-8 -*-
# @Author: Wick
# @Time: 2024-02-23 21:25

info_tuple = ("zhangsan", 18, 1.75, "zhangsan")
# 1. 取值和取索引
print(info_tuple[0])
# 已经知道数据的内容，希望知道该数据在元组中的索引
print(info_tuple.index("zhangsan"))
# 2. 统计计数
print(info_tuple.count("zhangsan"))
# 统计元组中包含元素的个数
print(len(info_tuple))

info_tuple = ()
print(type(info_tuple))
info_tuple = (1)
print(type(info_tuple))
info_tuple = (1,)
print(type(info_tuple))

info_tuple = ("小明", 21, 1.85)
# 格式化字符串后面的 `()` 本质上就是元组
print("%s 年龄是 %d 身高是 %.2f" % info_tuple)
info_str = "%s 年龄是 %d 身高是 %.2f" % info_tuple
print(info_str)

info_str1 = '{} 年龄是 {} 身高是 {}'.format(info_tuple[0], info_tuple[1], info_tuple[2])
print(info_str1)
print("-"*50)
info_list = list(info_tuple)
print(info_list)

info_tuple2 = tuple(info_list)
print(info_tuple2)